from flask.blueprints import Blueprint
from toutiaoapi.restful import BaseApi
from . import views, detail, comment  # 导入视图

# 创建蓝图
home_blueprint = Blueprint('home', __name__, url_prefix='/app/v1_0')

# Api接管蓝图
home_api = BaseApi(home_blueprint)

# 添加路由
home_api.add_resource(views.Index2Resource, '/index')
# 获取所有频道
home_api.add_resource(views.ChannelsResource, '/channels')
# 获取用户关注频道
home_api.add_resource(views.UserChannelsResource, '/user/channels')
# 获取频道对应的文章
home_api.add_resource(views.IndexResource, '/articles')
# 获取文章详情
home_api.add_resource(detail.DetailResource, '/articles/<article_id>')
# 关注作者
home_api.add_resource(detail.FollowResource, '/user/followings')
# 取消关注作者
home_api.add_resource(detail.FollowDeleteResource, '/user/followings/<target>')
# 文章点赞
home_api.add_resource(detail.ArticleLikeResource, '/article/likings')
# 文章取消点赞
home_api.add_resource(detail.ArticleLikeDeleteResource, '/article/likings/<target>')
# 文章选择不喜欢
home_api.add_resource(detail.DislikeResource, '/article/dislikes')
# 文章取消不喜欢
home_api.add_resource(detail.DisLikeDeleteResource, '/article/dislikes/<target>')
# 收藏文章
home_api.add_resource(detail.CollectionResource, '/article/collections')
# 取消收藏
home_api.add_resource(detail.CollectionDeleteResource, '/article/collections/<target>')
# 文章评论
home_api.add_resource(comment.CommentsResource, '/comments')
# 评论点赞
home_api.add_resource(comment.CommentLikingResource, '/comment/likings')
# 展示阅读历史
home_api.add_resource(detail.ReadingHistoryResource, '/user/histories')
# 粉丝列表展示
home_api.add_resource(detail.FansResource, '/user/followers')
